//
//  NSObject+CYBugly.m
//  CreditAddressBook
//
//  Created by LE on 15/12/8.
//  Copyright © 2015年 Lee. All rights reserved.
//

#import "NSObject+CYBugly.h"

@implementation NSObject (CYBugly)

- (void)reportException:(NSException *)exc {
    [[CrashReporter sharedInstance] reportException:exc reason:[NSString stringWithFormat:@"%@---抛出异常", [self class]] extraInfo:nil];
}

- (void)reportError:(NSError *)err {
    [[CrashReporter sharedInstance] reportError:err reason:[NSString stringWithFormat:@"%@---抛出错误", [self class]] extraInfo:nil];
}

- (void)reportException:(NSException *)exc reason:(NSString *)reason {
    [[CrashReporter sharedInstance] reportException:exc reason:reason extraInfo:nil];
}

- (void)reportError:(NSError *)err reason:(NSString *)reason {
    [[CrashReporter sharedInstance] reportError:err reason:reason extraInfo:nil];
}

+ (void)reportException:(NSException *)exc reason:(NSString *)reason {
    [[CrashReporter sharedInstance] reportException:exc reason:reason extraInfo:nil];
}

+ (void)reportError:(NSError *)err reason:(NSString *)reason {
    [[CrashReporter sharedInstance] reportError:err reason:reason extraInfo:nil];
}

+ (void)reportReason:(NSString *)reason {
    [[CrashReporter sharedInstance] reportError:nil reason:reason extraInfo:nil];
}

#pragma mark - log
+ (void)logWarn:(NSString *)warn {
    [BuglyLog initLogger:BLYLogLevelWarn consolePrint:NO];
    BLogWarn(@"%@", warn);
}

- (void)logWarn:(NSString *)warn {
    [NSObject logWarn:warn];
}

+ (void)logError:(NSString *)error {
    [BuglyLog initLogger:BLYLogLevelError consolePrint:NO];
    BLogWarn(@"%@", error);
}

- (void)logError:(NSString *)error {
    [NSObject logWarn:error];
}

+ (void)reportReason:(NSString *)reason logWarn:(NSString *)warn {
    [[CrashReporter sharedInstance] reportError:nil reason:reason extraInfo:nil];
    [self logWarn:warn];
}

- (void)reportReason:(NSString *)reason logWarn:(NSString *)warn {
    [NSObject reportReason:reason logWarn:warn];
}

+ (void)reportError:(NSError *)err reason:(NSString *)reason logError:(NSString *)error {
    [[CrashReporter sharedInstance] reportError:err reason:reason extraInfo:nil];
    [self logError:error];
}

- (void)reportError:(NSError *)err reason:(NSString *)reason logError:(NSString *)error {
    [NSObject reportError:err reason:reason logError:error];
}
@end
